package com.jingyanzi.channel.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.jingyanzi.channel.domain.ChannelDO;
import com.jingyanzi.channel.domain.ChannelTypeDO;
import com.jingyanzi.channel.domain.ChannelWindowDO;
import com.jingyanzi.channel.domain.ContactsDO;
import com.jingyanzi.channel.entity.Channel;
import com.jingyanzi.channel.entity.Channeltype;
import com.jingyanzi.channel.entity.Channelwindow;
import com.jingyanzi.channel.entity.Contacts;
import com.jingyanzi.channel.util.BeanUtilsExtends;

/**
 * @author reagan
 * @Description:基础服务类主要用来实现底层的通用方法
 */
public class BaseServiceImpl {
	
	public boolean isNumberNotEmpty(Integer value) {
		if(value == null) return false;
		else if(value == 0) return false;
		return true;
	}


	/**
	 * 对象拷贝单个实体到对象中
	 * 
	 * @param maAccountDiscount
	 * @return 返回DO对象
	 */
	public ChannelDO getChannelDO(Channel channel) {
		if (channel == null)
			return null;
		ChannelDO dst = new ChannelDO();
		return BeanUtilsExtends.copyProperties(dst, channel) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<ChannelDO> getChannelDOList(List<Channel> list) {
		List<ChannelDO> result = new ArrayList<ChannelDO>();
		if (list != null && !list.isEmpty()) {
			for (Channel org : list) {
				ChannelDO org1 = getChannelDO(org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}

	/**
	 * 对象拷贝单个实体到对象中
	 * 
	 * @param obj
	 * @return 返回DO对象
	 */
	public ChannelTypeDO getChannelTypeDO(Channeltype obj) {
		if (obj == null)
			return null;
		ChannelTypeDO dst = new ChannelTypeDO();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<ChannelTypeDO> getChannelTypeDOList(List<Channeltype> list) {
		List<ChannelTypeDO> result = new ArrayList<ChannelTypeDO>();
		if (list != null && !list.isEmpty()) {
			for (Channeltype org : list) {
				ChannelTypeDO org1 = getChannelTypeDO(org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}

	/**
	 * 对象拷贝单个实体到对象中
	 * 
	 * @param obj
	 * @return 返回DO对象
	 */
	public ChannelWindowDO getChannelWindowDO(Channelwindow obj) {
		if (obj == null)
			return null;
		ChannelWindowDO dst = new ChannelWindowDO();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<ChannelWindowDO> getChannelWindowDOList(List<Channelwindow> list) {
		List<ChannelWindowDO> result = new ArrayList<ChannelWindowDO>();
		if (list != null && !list.isEmpty()) {
			for (Channelwindow org : list) {
				ChannelWindowDO org1 = getChannelWindowDO(org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}

	public ContactsDO getContactsDO(Contacts obj) {
		if (obj == null)
			return null;
		ContactsDO dst = new ContactsDO();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<ContactsDO> getContactsDOList(List<Contacts> list) {
		List<ContactsDO> result = new ArrayList<ContactsDO>();
		if (list != null && !list.isEmpty()) {
			for (Contacts org : list) {
				ContactsDO org1 = getContactsDO(org);
				if (org1 != null) {
					if (org1.getGender() != null) {
						if (org1.getGender() == 1) {
							org1.setGenderName("男");
						} else if (org1.getGender() == 2) {
							org1.setGenderName("女");
						}
					}

					result.add(org1);
				}
			}
		}
		return result;
	}
}
